package org.budo.support.spring.http.converter.json;

import org.budo.support.lang.util.ListUtil;
import org.springframework.http.MediaType;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;

import lombok.extern.slf4j.Slf4j;

/**
 * BudoFastJsonHttpMessageConverter
 */
@Slf4j
public class BudoFastJsonHttpMessageConverter extends FastJsonHttpMessageConverter {
    public BudoFastJsonHttpMessageConverter() {
        this.setSupportedMediaTypes(ListUtil.toList(MediaType.valueOf("application/json;charset=UTF-8")));

        FastJsonConfig fastJsonConfig = new FastJsonConfig();
        fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
        this.setFastJsonConfig(fastJsonConfig);

        log.warn("#25 after init BudoFastJsonHttpMessageConverter, this=" + this);
    }
}